<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  var arr = function (s) {
    let res = []
    let max = 0
    for (let str of s) {
      while (res.includes(str)) {
        res.shift()
      }
      res.push(str)
      max = Math.max(max, res.length)
    }
    return max
  };
  console.log(arr(s = "abcabcbb"));
</script>

</html>